# ******************************************************
SUBDIRS = ../utils

# Variables
DEFS = -Wall -DLINUX

# Libraries
LIB_PATH = -L../lib
LIB = -lpthread -lutils -lrt

# Includes
INCLUDES = -I../include

# Object files
OBJ_PATH = obj

#Binary
BIN_PATH = bin
BIN = $(BIN_PATH)/box_server

CXX = g++
CXXFLAGS = $(DEFS) $(INCLUDES)
# ******************************************************

help info:
	@echo 'Usage: make {install | clean | help, info }'

install:
	@echo '--------------Compiling referenced source files------------------'
	for dir in ${SUBDIRS} ; do (cd $$dir; make install); done
	
	@echo '--------------Compiling of source files--------------------------'
	mkdir -p $(OBJ_PATH)
	$(CXX) $(CXXFLAGS) -c box_server.cpp -o $(OBJ_PATH)/box_server.o
	$(CXX) $(CXXFLAGS) -c user_profile.cpp -o $(OBJ_PATH)/user_profile.o
	$(CXX) $(CXXFLAGS) -c user_box.cpp -o $(OBJ_PATH)/user_box.o
	$(CXX) $(CXXFLAGS) -c box_connection.cpp -o $(OBJ_PATH)/box_connection.o
	
	#$(CXX) $(CXXFLAGS) -c file_logger.cpp -o $(OBJ_PATH)/file_logger.o
	#$(CXX) $(CXXFLAGS) -c sys_logger.cpp -o $(OBJ_PATH)/sys_logger.o
	
	$(CXX) $(CXXFLAGS) -c main.cpp -o $(OBJ_PATH)/main.o

	@echo '--------------Linking of object files----------------------------'
	mkdir -p $(BIN_PATH)
	$(CXX) $(DEFS) $(OBJ_PATH)/*.o $(LIB_PATH) $(LIB) -o $(BIN) 

clean:
	@echo '--------------Removing temporary files---------------------------'
	for dir in ${SUBDIRS} ; do (cd $$dir; make clean); done
	@rm -rf $(OBJ_PATH) $(BIN_PATH)
